﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PwdGen
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage:\n\tPwdGen <password length>");
                return;
            }

            var len = 0;
            try
            {
                len = Convert.ToInt32(args[0]);
            }
            catch {
                Console.WriteLine("Usage:\n\tPwdGen <password length>");
                return;
            }

            var pwdChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=[];'\\/.,~!@#$%^&*()_+{}:\"|?><";
            var result = string.Empty;
            var rnd = new Random();

            for (int i = 0; i < len; ++i)
            {
                result += pwdChars[rnd.Next(pwdChars.Length)];
            }

            Console.WriteLine(result);
        }
    }
}
